package TestApp;


import Questions.Question;
import Users.AnswerReport;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Myhaylo Kotsyuruba
 * @version v.1.4   14.03.13
 */

public class Test {
    private String name;
    private ArrayList<Question> questions;

    public Test(String name, List<Question> questions) {
        this.name = name;
        this.questions = new ArrayList<Question>(questions);
    }

    @Override
    public String toString() {
        return "\n" + name;
    }

    public String toStringQuestion(int index) {
        String numberString = String.format("%n  Question %d: ", (index + 1));
        String textOfQuestion = questions.get(index).toString();
        return numberString.concat(textOfQuestion);
    }

    public int getQuantityQuestions() {
        return questions.size();
    }

    public AnswerReport createAnswerReport(int indexQuestion, String answer) throws MyNonNumberException {
        Question question = questions.get(indexQuestion);
        return question.getAnswerReport(answer);
    }

    public void showQuestion(int index) {
        String question = toStringQuestion(index);
        IOSystem.show(question);
    }
}

